/***
  author: sailing
  date: 2016/11/16
**/
import axios from 'axios'
import tools from './tools'
import eventBus from '../eventBus'
export default {
  getJson (config) {
    const url = tools.mergeUrl(config.url)
    eventBus.bus.$emit('showLoading')
    axios.get(url)
      .then(function (response) {
        eventBus.bus.$emit('hideLoading')
        config.callback.call(config.self, response.data)
      })
      .catch(function (error) {
        eventBus.bus.$emit('hideLoading')
        console.log('get error:', error)
      })
  }
}
